﻿@model PasswordManagerMVC.Models.SearchModel

@{
    ViewBag.Title = "Search";
}

<script type="text/javascript">
    function hclick() {
        $.ajax({
            type: "POST",
            url: "/PMService.svc/DoWork",
            data: '{ "name": "Tyreel" }',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                alert(result.d);
            },
            error: function(data) {
                alert(data.responseText);
            },
        });
    }
</script>

@using (Html.BeginForm("Search", "Search", FormMethod.Get))
{
@Html.ValidationSummary(true)
<div>
    <div class="editor-label">
        <label for="SearchText">Input search string: </label>
    </div>
    <div class="editor-field">
        @Html.EditorFor(s => s.SearchText)
        @Html.ActionLink("Add New", "AddNew")
    </div>
    <p>
        <input type="submit" value="Search" />
    </p>
</div>
}

<table id="searchResult">
    <tr>
        <th>
            
        </th>
        <th>
            User Name
        </th>
        <th>
            Password
        </th>
        <th>
            Tag1
        </th>
        <th>
            Tag2
        </th>
        <th>
            Tag3
        </th>
        <th>
            Tag4
        </th>
        <th>
            Tag5
        </th>
    </tr>

@foreach (var item in Model.Results) {
    <tr>
        <td>
            @Html.ActionLink("Delete", "Delete", new { id = item.ID })
            | <a onclick="hclick()" href="#">click</a>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.UserName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Password)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Tag1)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Tag2)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Tag3)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Tag4)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Tag5)
        </td>
    </tr>
}

</table>
